package com.unitechs.controller.pattern;

import com.unitechs.commons.utils.ZyucPatternUtil;

import java.util.ArrayList;
import java.util.List;

public class PatternTest {
    public static void main(String[] args) {
        zyucIsContainsPattern();
        //zyucIsRegexPattern();
        //zyucMatchesAny();
    }

    public static void zyucIsContainsPattern(){
        String str="41akjfbafo oid:192.168.0.1 i#$!@fdaofu9r";
        String regex="oid\\s*:\\s*\\d+(.\\d+){3}";
        boolean b = ZyucPatternUtil.zyucIsContainsPattern(str, regex);
        System.out.println(b);
    }

    public static void zyucIsRegexPattern(){
        String regex="oid\\s*:\\s*\\d+(.\\d+){3}";
        String str="[213fsd53208#$@";
        String other="oid:192.168.0.1";

        boolean b = ZyucPatternUtil.zyucIsRegexPattern(regex);
        System.out.println(b);
        boolean b1 = ZyucPatternUtil.zyucIsRegexPattern(str);
        System.out.println(b1);
        boolean b2 = ZyucPatternUtil.zyucIsRegexPattern(other);
        System.out.println(b2);
    }

    public static void zyucMatchesAny(){
        String regex1="(admin)? sh(ow)? .*";
        String regex2="sh(ow)? running-config .*";
        List<String> regexs=new ArrayList<>();
        regexs.add(regex1);
        regexs.add(regex2);

        String str="sh running-config";
        boolean b = ZyucPatternUtil.zyucMatchesAny(str, regexs);
        System.out.println(b);

    }
}
